
function generate_tags(event){
	if(event.isLeftClick()){
		
		//disable generate button
		//event.element().disable();
		//and disable submit next button
		var form_elt = event.findElement('form');
		//disable all the submit buttons
		
		form_elt.getInputs('submit').invoke('disable');
		
		//display busy indicator
		//alert(event.element().up().tagName());
		event.element().up().previous('.tags_col').update("<img src="+contextPath+"/image/busy-indicator.gif alt='busy generating tags...'/>");
		var paras = form_elt.serialize({hash:true});
		paras[event.element().name] = event.element().value;
		form_elt.request({
			parameters: paras,
			onSuccess: function(response){
				var res = response.responseJSON;
				event.element().up().previous('.tags_col').update(res.tags.join(','));
				form_elt.getInputs('submit').invoke('enable');
			},
			onFailure: function(response){
				var res = response.responseJSON();
				event.element().up().previous('.tags_col').update(res.message);
				form_elt.getInputs('submit').invoke('enable');
			}
		});
		event.stop();
	}
	
}




document.observe('dom:loaded',function(e){
	$('gen_tag_btn').observe('click', generate_tags);
});
